
module.exports = {
  setStrategyByNewUpDown () {
    if (
      this.analysisInfo1h.lastEma5W10A20KeepInfo.maxCloseRate >= 200 ||
      this.analysisInfo1h.lastEma5A10KeepInfo.maxCloseRate >= 200
    ) {
      // 挺好的
      this.setStrategy('1', 'ud-1')
      return true
    }
    return false
  },
  setStrategyBySpecialMarket () {
    if (this.btbItem.price_change_percent) {
      if (this.btbItem.price_change_percent < -40 && this.indexFlagInfo.isIndexCloseNewLow) {
        // 这种极端的基本就是正向，然后配合reason的卖出
        this.setStrategy('1', 'pcp-2')
        return true
      }
    }
    return false
  },
  setStrategyByNewHighLow () {
    return false
  },
  setStrategyByBeforeConfig () {
    return false
  },
  setForwardStrategyByKdjKeepManyDays () {
    if (
      (this.analysisInfo15m.ema5W10A20Days >= 80) &&
      !(this.analysisInfo15m.macd > 0 && this.analysisInfo15m.macdUpDays <= 4) &&
      this.indexFlagInfo.isIndexCloseNowNewHigh
      // 不要再改了，越改越错
    ) {
      // 这个策略也会有挣大钱的时候，盈亏比好，即使4h的kdj都往下
      // 查一下交易数据其实还行
      this.setStrategy('1', 's-1-6')
      return true
    }
    if (
      // 10>20的时间长，外加24小时涨幅很大，就跟强势，很离谱，逼空的
      // 或者是156，再或者配合24小时涨幅大于100
      (this.analysisInfo15m.ema10A20Days >= 128) &&
      !(this.analysisInfo15m.macd > 0 && this.analysisInfo15m.macdUpDays <= 4) &&
      this.indexFlagInfo.isIndexCloseNowNewHigh
    ) {
      this.setStrategy('1', 's-1-6-1')
      return true
    }
    return false
  },
  setForwardStrategyByEmaShuttle () {
    return false
  },
  setForwardStrategyByMarketResonance () {
    return false
  },
  setForwardStrategyByItemTrend () {
    if (
      this.analysisInfo1d.ema5W10B20Days >= 16 &&
      (this.analysisInfo1d.ema5B10B20Days >= 1 && this.analysisInfo1d.ema5B10B20Days <= 3) &&
      this.analysisInfo4h.isKong &&
      this.analysisInfo4h.ema5W10B20Days >= 4 &&
      this.analysisInfo4h.macdDownDays >= 4 &&
      this.analysisInfo4h.kdjDownDays >= 4 &&
      this.analysisInfo1h.isKong &&
      this.analysisInfo1h.ema5W10B20Days >= 16 &&
      this.analysisInfo1h.macdDownDays >= 4 &&
      this.analysisInfo1h.kdjDownDays >= 4 &&
      this.marketInfo.macd1dBad
    ) {
      this.setStrategy('1', 's-4-2')
      return true
    }
    if (
      this.analysisInfo1d.kdjDiff < 0 &&
      this.analysisInfo4h.isKong &&
      this.analysisInfo4h.ema5W10B20Days >= 4 &&
      this.analysisInfo4h.macdDownDays >= 20 &&
      this.analysisInfo1h.isKong &&
      this.analysisInfo1h.ema5W10B20Days >= 4 &&
      this.analysisInfo1h.macdDownDays >= 4 &&
      this.analysisInfo1h.kdjDownDays >= 4 &&
      this.marketInfo.macd1dBad &&
      (this.marketInfo.kdj1dBad || this.marketInfo.macd4hBad)
    ) {
      this.setStrategy('1', 's-4-3')
      return true
    }
    if (
      this.analysisInfo1d.ema5W10B20Days >= 20 &&
      this.analysisInfo4h.lastKdjUpDays >= 10 &&
      this.analysisInfo4h.close < this.analysisInfo4h.ema5 &&
      this.analysisInfo4h.close < this.analysisInfo4h.ema10 &&
      this.analysisInfo4h.close < this.analysisInfo4h.ema20 &&
      this.analysisInfo1h.isKong &&
      this.analysisInfo1h.kdjDownDays >= 10 &&
      (this.marketInfo.kdj1dBad || this.marketInfo.macd4hBad)
    ) {
      this.setStrategy('1', 's-4-4')
      return true
    }
    // 下一个s-4-5
    return false
  },
  setForwardStrategyBySpecialAnalysis () {
    if (
      (this.analysisInfo1d.isLongDuo && this.analysisInfo1d.ema5W10A20Days >= 2 && this.analysisInfo1d.macdUpDays >= 30) &&
      (
        this.analysisInfo4h.netChangeRatio > 0 &&
        (
          (this.analysisInfo4h.ema5A20Days >= 1 && this.analysisInfo4h.ema5A20Days <= 3) ||
          (this.analysisInfo4h.ema5A10A20Days === 1)
        )
      ) &&
      (
        this.analysisInfo1h.netChangeRatio > 0 &&
        this.analysisInfo1h.kdjUpDays >= 7 &&
        this.analysisInfo1h.macdUpDays >= 4 &&
        this.analysisInfo1h.ema5A20Days >= 1
      ) &&
      (
        this.analysisInfo15m.netChangeRatio > 0 &&
        this.analysisInfo15m.kdjUpDays >= 1 &&
        this.analysisInfo15m.macdUpDays >= 32 &&
        this.analysisInfo15m.ema5W10A20Days >= 10
      ) &&
      this.marketFlagInfo.ifMarket4hHasGood
    ) {
      this.setStrategy('1', 's-5-1')
      return true
    }
    const countModel15m = (this.marketInfo && this.marketInfo.countModel15m) || {}
    if (
      (this.analysisInfo1d.ema5W10B20Days >= 1) &&
      (
        this.analysisInfo4h.netChangeRatioDownDays >= 3 &&
        this.analysisInfo4h.kdjDownDays >= 6 &&
        this.analysisInfo4h.isKdjDecline &&
        this.analysisInfo4h.close < this.analysisInfo4h.ema5 &&
        this.analysisInfo4h.close < this.analysisInfo4h.ema10 &&
        this.analysisInfo4h.close < this.analysisInfo4h.ema20
      ) &&
      (
        this.analysisInfo1h.isKdjDecline &&
        this.analysisInfo1h.kdjDownDays >= 5 &&
        this.analysisInfo1h.netChangeRatioDownDays >= 5
      ) &&
      (this.marketInfo && this.marketInfo.likeKong && (countModel15m.countKdjDown / this.marketInfo.asCount) > 0.45)
    ) {
      this.setStrategy('1', 's-5-5')
      return true
    }
    if (
      (this.analysisInfo1d.ema5W10B20Days >= 30) &&
      (
        this.analysisInfo4h.netChangeRatioDownDays >= 3 &&
        this.analysisInfo4h.isKdjDecline &&
        this.analysisInfo4h.close < this.analysisInfo4h.ema5 &&
        this.analysisInfo4h.close < this.analysisInfo4h.ema10 &&
        this.analysisInfo4h.close < this.analysisInfo4h.ema20
      ) &&
      (
        this.analysisInfo1h.close < this.analysisInfo1h.ema5 &&
        this.analysisInfo1h.close < this.analysisInfo1h.ema10 &&
        this.analysisInfo1h.close < this.analysisInfo1h.ema20 &&
        this.analysisInfo1h.ema5 < this.analysisInfo1h.ema20 &&
        this.analysisInfo1h.ema5B10Days >= 2 &&
        this.analysisInfo1h.macdDownDays >= 2 &&
        (
          (
            this.analysisInfo1h.kdjDownDays >= 4 &&
            this.analysisInfo1h.netChangeRatioDownDays >= 4
          ) ||
          (
            this.analysisInfo1h.kdjDownDays >= 10 &&
            this.analysisInfo1h.netChangeRatioDownDays >= 2
          )
        )
      ) &&
      this.analysisInfo15m.isLongKong &&
      this.analysisInfo15m.macdDownDays >= 10 &&
      this.analysisInfo15m.ema5W10B20Days >= 10
    ) {
      this.setStrategy('1', 's-5-6')
      return true
    }
    if (
      (this.analysisInfo1d.ema5W10B20Days >= 30) &&
      (
        this.analysisInfo4h.netChangeRatioDownDays >= 3 &&
        this.analysisInfo4h.kdjDownDays > 10 &&
        this.analysisInfo4h.ema5B10B20Days >= 6 &&
        this.analysisInfo4h.macdDownDays >= 20
      ) &&
      (
        this.analysisInfo1h.ema5B10B20Days >= 20 &&
        this.analysisInfo1h.macdDownDays >= 20
      )
    ) {
      this.setStrategy('1', 's-5-7')
      return true
    }
    if (
      (this.analysisInfo1d.kdjDiff < 0) &&
      (
        this.analysisInfo4h.netChangeRatioDownDays >= 2 &&
        this.analysisInfo4h.kdjDownDays > 8 &&
        this.analysisInfo4h.ema5B10Days >= 2 &&
        this.analysisInfo4h.macdDownDays >= 32
      ) &&
      (
        this.analysisInfo1h.isLongKong &&
        this.analysisInfo1h.macdDownDays > 4 &&
        this.analysisInfo1h.ema5B10B20Days > 4 &&
        this.analysisInfo1h.kdjDiff < 0
      )
    ) {
      this.setStrategy('1', 's-5-8')
      return true
    }
    if (
      this.analysisInfo4h.ema5W10B20Days >= 10 &&
      this.analysisInfo4h.macdDownDays >= 10 &&
      this.analysisInfo4h.ema5B10Days === 1 &&
      this.analysisInfo1h.isKong &&
      this.analysisInfo1h.kdjDownDays >= 15 &&
      this.analysisInfo15m.isKong &&
      this.analysisInfo15m.ema5W10B20Days >= 20
    ) {
      this.setStrategy('1', 's-7-1')
      return true
    }
    if (
      this.analysisInfo1d.macd < 0 &&
      this.analysisInfo1d.ema10A20Days > 20 &&
      this.analysisInfo1d.lastEma5A10Days > 20 &&
      this.analysisInfo1d.ema5B10Days >= 1 &&
      this.analysisInfo1d.kdjDownDays >= 3 &&
      this.analysisInfo1d.ema5B20Days <= 1 &&
      this.analysisInfo4h.ema10B20Days >= 12 &&
      this.analysisInfo4h.ema5B10B20Days >= 2 &&
      this.analysisInfo4h.macdDownDays >= 12 &&
      this.analysisInfo4h.kdjDownDays >= 2 &&
      this.analysisInfo4h.isMacdDecline &&
      this.analysisInfo1h.ema5B10B20Days >= 4 &&
      this.analysisInfo1h.macdDownDays >= 4 &&
      (
        this.marketFlagInfo.ifMarket4hHasBad ||
        this.marketFlagInfo.ifMarket1dHasBad
      )
    ) {
      this.setStrategy('1', 's-7-2')
      return true
    }
    if (
      this.analysisInfo4h.ema5W10A20KeepInfo.maxCloseRate >= 50 &&
      this.analysisInfo4h.kdjDiff < 0 &&
      this.analysisInfo4h.isMacdDecline &&
      this.analysisInfo4h.ema5W10A20Days < 20 &&
      (
        this.analysisInfo1h.ema5W10B20Days >= 1 ||
        (
          this.analysisInfo1h.macdDownDays >= 8 &&
          this.analysisInfo1h.kdjDownDays >= 3 &&
          this.analysisInfo1h.ema5B10Days >= 3 &&
          this.analysisInfo1h.close < this.analysisInfo1h.ema20
        )
      ) &&
      this.analysisInfo1h.macdDownDays >= 5 &&
      this.analysisInfo1h.kdjDiff < 0 &&
      (
        this.marketFlagInfo.ifMarket4hHasBad ||
        this.marketFlagInfo.ifMarket1dHasBad
      )
    ) {
      this.setStrategy('1', 's-7-3')
      return true
    }
    if (
      this.analysisInfo4h.lastEma5W10A20KeepInfo.maxCloseRate >= 50 &&
      this.analysisInfo4h.kdjDiff < 0 &&
      this.analysisInfo4h.isMacdDecline &&
      this.analysisInfo4h.lastEma5W10A20Days < 20 &&
      (
        this.analysisInfo1h.ema5W10B20Days >= 1 ||
        (
          this.analysisInfo1h.macdDownDays >= 8 &&
          this.analysisInfo1h.kdjDownDays >= 3 &&
          this.analysisInfo1h.ema5B10Days >= 3 &&
          this.analysisInfo1h.close < this.analysisInfo1h.ema20
        )
      ) &&
      this.analysisInfo1h.macdDownDays >= 5 &&
      this.analysisInfo1h.kdjDiff < 0 &&
      (
        this.marketFlagInfo.ifMarket4hHasBad ||
        this.marketFlagInfo.ifMarket1dHasBad
      )
    ) {
      if (this.analysisInfo4h.ema5B20Days === 1 && this.analysisInfo4h.ema10A20Days >= 5) {
        this.setStrategy('1', 's-7-3-1')
        return true
      }
    }
    if (
      !(this.marketInfo.macd4hGood || this.marketInfo.macd1hGood) &&
      this.analysisInfo1d.macd < 0 &&
      this.analysisInfo4h.ema5B10Days >= 1 &&
      (this.analysisInfo4h.ema5W10B20Days <= 1) &&
      (this.analysisInfo4h.close < this.analysisInfo4h.ema20) &&
      this.analysisInfo4h.macd < 0 &&
      this.analysisInfo4h.netChangeRatioDownDays >= 3 &&
      this.analysisInfo4h.kdjDownDays >= 3 &&
      this.analysisInfo4h.lastKdjUpDays >= 12 &&
      this.analysisInfo1h.macdDownDays >= 32 &&
      this.analysisInfo1h.kdjDownDays >= 10 &&
      this.analysisInfo1h.ema5W10B20Days >= 4 &&
      this.analysisInfo1h.ema5W10B20Days < 13 &&
      this.analysisInfo1h.lastEma5W10A20Days >= 32 &&
      this.analysisInfo15m.ema5W10B20Days >= 16
    ) {
      this.setStrategy('1', 's-7-4-1')
      return true
    }
    if (
      (this.marketInfo.macd4hBad && this.marketInfo.kdj1dBad) &&
      this.analysisInfo1d.macd > 0 &&
      this.analysisInfo1d.ema5W10A20Days >= 1 &&
      this.analysisInfo1d.kdjDiff < 0 &&
      (
        this.analysisInfo4h.ema5W10A20Days >= 16 ||
        this.analysisInfo4h.lastEma5W10A20Days >= 16
      ) &&
      this.analysisInfo4h.ema5B10Days >= 1 &&
      (this.analysisInfo4h.ema5W10B20Days <= 1) &&
      (this.analysisInfo4h.close < this.analysisInfo4h.ema20) &&
      this.analysisInfo4h.macd < 0 &&
      this.analysisInfo4h.kdjDownDays >= 5 &&
      this.analysisInfo1h.isLongKong
    ) {
      // 挺好的策略，挣了好多笔了
      this.setStrategy('1', 's-7-4-2')
      return true
    }
    if (
      this.analysisInfo1d.macd > 0 &&
      this.analysisInfo1d.isMacdDecline > 0 &&
      this.analysisInfo1d.ema5A10A20Days >= 1 &&
      this.analysisInfo1d.kdjDiff < 0 &&
      (
        this.analysisInfo4h.ema5W10A20Days >= 32 ||
        this.analysisInfo4h.lastEma5W10A20Days >= 32
      ) &&
      this.analysisInfo4h.ema5B10Days >= 1 &&
      (this.analysisInfo4h.ema5W10B20Days <= 1) &&
      (this.analysisInfo4h.close < this.analysisInfo4h.ema20) &&
      this.analysisInfo4h.macdDownDays >= 2 &&
      this.analysisInfo4h.kdjDiff < 0 &&
      this.analysisInfo1h.isLongKong &&
      this.analysisInfo1h.kdjDownDays >= 16
    ) {
      this.setStrategy('1', 's-7-4-3')
      return true
    }
    if (
      this.marketMachine.ifMarket1dModelLike([0, 0, 1]) &&
      this.marketMachine.ifMarket1dModelLike([[0, 1], 1, 0])
    ) {
      // if (this.indexFlagInfo.isIndexInNewHighTrend && this.analysisInfo1d.macdUpDays === 1) {
      //   if (this.analysisInfo4h.isLongDuo && this.analysisInfo1h.isLongDuo) {
      //     this.setStrategy('1', 's-8-1')
      //     return true
      //   }
      // }
      if (
        this.indexFlagInfo.isIndexInNewHighTrend &&
        this.analysisInfo1d.isDuo &&
        this.analysisInfo1d.isKdjIncrease &&
        this.analysisInfo1d.macdUpDays >= 16 &&
        this.analysisInfo1d.isMacdIncrease &&
        this.analysisInfo1d.ema5W10A20Days >= 16
      ) {
        if (
          this.analysisInfo4h.isDuo &&
          this.analysisInfo4h.isKdjIncrease &&
          this.analysisInfo4h.macdUpDays >= 12 &&
          this.analysisInfo4h.isMacdIncrease &&
          this.analysisInfo4h.ema5W10A20Days >= 12 &&
          this.analysisInfo1h.isLongDuo
        ) {
          this.setStrategy('1', 's-8-2')
          return true
        }
      }
    }
    return false
  },
  setStrategyBySpecialMarketTrend () {
    if (this.marketMachine.ifMarketModelLike(
      [[1, 1, 0], [-1, 0, 1], [-1, -1, 0], [[-1, 0], -1, [-1, 0]]]
    )) {
      this.setStrategy('1', 'smt-0001')
      return true
    }
    if (this.marketMachine.ifMarketModelLike(
      [[0, 1, 0], [[0, -1], -1, 0], [-1, 0, [0, -1]], [-1, -1, -1]]
    )) {
      this.setStrategy('1', 'smt-0002')
      return true
    }
    if (this.marketMachine.ifMarketInModel([
      [[[0, -1], 1, 0], [-1, -1, 0], [-1, -1, -1], [[0, -1], -1, -1]],
      [[0, 1, 0], [-1, -1, 0], [-1, -1, -1], [[0, -1, 1], -1, -1]]
    ])) {
      this.setStrategy('1', 'smt-0003')
      return true
    }
    if (this.marketFlagInfo.isMarketChaos) {
      if (this.marketMachine.ifMarketInModel([
        '[[0,0,0],[-1,0,0],[-1,-1,0],[-1,-1,-1]]',
        '[[0,0,0],[0,0,0],[0,-1,0],[-1,0,0]]',
        '[[0,0,0],[0,0,0],[-1,-1,0],[-1,0,-1]]'
      ])) {
        // if (this.analysisInfo15m.macd < 0 || this.analysisInfo15m.ema5B10Days >= 1) {
        // }
        this.setStrategy('1', 'smt-0004')
        return true
      }
    }
    if (this.marketMachine.ifMarketInModel([
      '[[0,0,0],[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]]',
      '[[0,0,0],[-1,-1,-1],[-1,-1,-1],[0,-1,-1]]'
    ])) {
      this.setStrategy('1', 'smt-0005')
      return true
    }
    if (this.marketMachine.ifMarketInModel([
      '[[-1,0,0],[-1,-1,0],[0,0,-1],[-1,0,-1]]',
      '[[-1,0,0],[-1,-1,0],[0,0,-1],[-1,1,0]]'
    ])) {
      this.setStrategy('1', 'smt-0006')
      return true
    }
    if (this.marketMachine.ifMarketInModel([
      '[[-1,0,0],[-1,-1,-1],[-1,0,-1],[-1,-1,-1]]',
      '[[-1,0,0],[0,-1,-1],[-1,1,-1],[-1,-1,-1]]',
      '[[-1,0,0],[-1,-1,-1],[-1,1,-1],[-1,-1,-1]]',
      '[[-1,0,0],[-1,-1,-1],[-1,0,-1],[0,-1,-1]]',
      '[[-1,0,0],[-1,0,-1],[-1,0,-1],[-1,-1,-1]]'
    ])) {
      this.setStrategy('1', 'smt-0007')
      return true
    }
    if (
      this.marketMachine.ifMarketInModel([
        '[[-1,0,0],[-1,-1,0],[0,0,-1],[-1,-1,-1]]',
        '[[-1,0,0],[-1,-1,0],[-1,0,-1],[-1,-1,-1]]',
        '[[-1,0,0],[-1,-1,0],[-1,0,-1],[0,-1,-1]]',
        '[[-1,0,0],[-1,-1,0],[-1,-1,-1],[0,-1,-1]]',
        '[[-1,0,0],[-1,-1,0],[-1,-1,-1],[1,-1,-1]]',
        '[[-1,1,0],[-1,-1,0],[0,-1,-1],[-1,0,-1]]'
      ]) &&
      // 这里等4天，因为天的ema不是红的了
      !(this.marketFlagInfo.ifMarket15mAllBad4Days)
    ) {
      this.setStrategy('1', 'smt-0008')
      return true
    }
    if (
      this.marketMachine.ifMarketInModel([
        '[[1,0,0],[0,0,0],[[0,1],[0,1],[0,1]],[[0,1],[0,1],[0,1]]]'
      ]) &&
      !(this.marketFlagInfo.ifMarket15mAllBad4Days)
    ) {
      this.setStrategy('1', 'smt-0009')
      return true
    }
  }
}
